//
//  HJNavigationViewController.m
//  Sneakers
//
//  Created by 胡光健 on 2017/9/19.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "HJNavigationViewController.h"
#import "HJTabBarViewController.h"

@interface HJNavigationViewController ()<UINavigationControllerDelegate,UIGestureRecognizerDelegate>

@end

@implementation HJNavigationViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    //vself.popDelegate = self.interactivePopGestureRecognizer.delegate;
    self.interactivePopGestureRecognizer.delegate = self;
    [self.navigationBar setBackgroundImage:UIColor.whiteColor.image forBarMetrics:UIBarMetricsDefault];
    NSMutableDictionary *att = [NSMutableDictionary dictionary];
    att[NSFontAttributeName] = [UIFont systemFontOfSize:18];
    att[NSForegroundColorAttributeName] = [UIColor colorWithHex:0x000000];
    [self.navigationBar setTitleTextAttributes:att];
    [self.navigationBar setShadowImage:[UIImage new]];
//     self.navigationBar.translucent = NO;
//     self.navigationBar.backgroundColor = [UIColor colorWithHex:0xFFFFFF];
    
    self.delegate = self;
    self.navigationBar.tintColor = HJColorRGB(255);
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    if (self.viewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = YES;
        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[[UIImage imageNamed:@"back_black_left"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(back:)];
    }
    [super pushViewController:viewController animated:animated];
}
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
    if (self.viewControllers.count <= 1 ) {
        return NO;
    }
    return YES;
}
// 允许同时响应多个手势
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    return YES;
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    return [gestureRecognizer isKindOfClass: UIScreenEdgePanGestureRecognizer.class];
}

- (void)back:(UIBarButtonItem *)item {
    [self popViewControllerAnimated:YES];
}



@end
